package com.banter;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class CreateBanter extends Activity implements OnClickListener {
	
	private Button m_createButton;
	private EditText m_Title;
	private EditText m_Body;
	private String body;
	private String title;
	private double lat=0.0;
	private double lng=0.0;

	
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_create_banter);
		initLayout();
		
		BanterLocationListener gps = new BanterLocationListener(CreateBanter.this);
		if(!gps.canGetLocation()){
			gps.showSettingsAlert();
		}else{
			lat = gps.getLat();
			lng = gps.getLong();
		}
		
		m_createButton.setOnClickListener(this);
	}
	
	protected void initLayout(){
    	m_createButton = (Button) this.findViewById(R.id.Create);
    	m_Title = (EditText) this.findViewById(R.id.editText1);
    	m_Body = (EditText) this.findViewById(R.id.editText2);
    }
	
    public void onClick(View v){
    	body = "-" + m_Body.getText().toString();
    	title = m_Title.getText().toString();
		Intent myIntent = new Intent(CreateBanter.this, ChatActivity.class);
		myIntent.putExtra("title",title);
		myIntent.putExtra("body",body);
		myIntent.putExtra("lattitude", lat);
		myIntent.putExtra("longitude", lng);
		startActivity(myIntent);
    
    }

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_create_banter, menu);
		return true;
	}

}
